package com.lagou.edu.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

/**
 * 封装handler方法相关的信息
 */
public class Handler {

    private Object controller;  // method.invoke需要传入

    private Method method;

    private Pattern pattern;    // Spring中url是支持正则的

    private Map<String, Integer> paramIndex;    // 参数顺序，是为了进行参数绑定，key是参数名，value是第几个参数

    private Set<String> userNameSet;

    public Handler(Object controller, Method method, Pattern pattern, Set<String> userNameSet) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.paramIndex = new HashMap<>();
        this.userNameSet = userNameSet;
    }

    // Getter && Setter
    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndex() {
        return paramIndex;
    }

    public void setParamIndex(Map<String, Integer> paramIndex) {
        this.paramIndex = paramIndex;
    }

    public Set<String> getUserNameSet() {
        return userNameSet;
    }

    public void setUserNameSet(Set<String> userNameSet) {
        this.userNameSet = userNameSet;
    }
}
